﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Jemgine.Engine.Scripts
{
    [Category("System"), Node]
    public class Hide : Data.ScriptNode
    {
        public Hide()
        {
            AddInput("Fire", null);
            AddReference("Entity", null);
            AddOutput("Relay", null);
        }

        public override void FireTerminal(int InputID, Data.ScriptPayload Payload)
        {
            if (ReferenceTerminals[0].GetTarget(Payload) != null &&
                ReferenceTerminals[0].GetTarget(Payload) is Data.EntityRecord)
                ( ReferenceTerminals[0].GetTarget(Payload) as Data.EntityRecord ).Hidden = true;
            OutputTerminals[0].Fire(Payload);
        }


    }

    [Category("System"), Node]
    public class ToggleVisibility : Data.ScriptNode
    {
        public ToggleVisibility()
        {
            AddInput("Fire", null);
            AddReference("Entity", typeof(Data.EntityRecord));
            AddOutput("Relay", null);
        }

        public override void FireTerminal(int InputID, Data.ScriptPayload Payload)
        {
            var Item = ReferenceTerminals[0].GetTarget(Payload);

            if (Item != null && Item is Data.EntityRecord)
            {
                var Record = Item as Data.EntityRecord;
                Record.Hidden = !Record.Hidden;
            }

            OutputTerminals[0].Fire(Payload);

        }


    }
}
